<template>
	<view class="category">

		<!-- 创意 -->
		<view class="idea" @click="goCategory(item.id)" v-for="item in list_front" :key="item.id">
			<view class="ideaName">
				{{item.name}}
			</view>
			<view class="ideaPic">
				<image :src="item.icon" mode=""></image>
			</view>
		</view>



		<!-- 饰品与灯具 -->
		<view class="downCom">
			<view class="dec" v-for="item in list_rear" :key="item.id" @click="goCategory(item.id)">
				<image :src="item.icon" mode=""></image>

				<view class="decName">
					{{item.name}}
				</view>
			</view>
		</view>





	</view>
</template>

<script>
	import {
		categorys
	} from "../../api/kind/index.js"
	export default {
		data() {
			return {
				list_front: [],
				list_rear: []
			};
		},
		onLoad() {
			categorys().then(res => {
				console.log(res)
				this.list_front = res.data.category.children.filter((item, index) => index < 2)
				this.list_rear = res.data.category.children.filter((item, index) => index >= 2)
				console.log("list_front", this.list_front)
				console.log('list_rear', this.list_rear)
			})
		},
		methods: {
			goCategory(val) {
				uni.navigateTo({
					url: `../kind/category/category?id=${val}`
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F1ECE7;
	}
</style>

<style lang="scss" scoped>
	.category {

		// 创意风格
		.idea {
			width: 335px;
			height: 151px;
			background: #d5d5d5;
			position: relative;
			margin: 28px auto;
			border-radius: 20px;
			box-shadow: 0 12px 20px 0 rgba(83, 66, 49, .05);

			.ideaName {
				position: absolute;
				left: 26px;
				top: 74px;
				font-size: 24px;
			}

			.ideaPic {
				image {
					float: right;
					width: 201px;
					height: 151px;
				}
			}
		}
		// 风格背景
		.idea:nth-child(2){
			background-color: #FFFFFF;
		}
		
		
		
		.downCom {
			display: flex;
			justify-content: space-around;

			// 饰品灯具
			.dec {
				width: 156px;
				height: 221px;
				position: relative;

				image {
					width: 156px;
					height: 221px;
				}

				.decName {
					position: absolute;
					left: 26px;
					top: 74px;
					font-size: 24px;
					color: #3e3e3e;
				}
			}

		}

	}
</style>
